package vq.codec.entities;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import vq.codec.util.Util;

public class Dictionary {

	private Map<Integer, List<Double>> dictionary = new HashMap<Integer, List<Double>>();
	private int quantizatorDimension;

	public Dictionary() {
		
	}

	public Dictionary(Map<Integer, List<Double>> dictionary,
			int quantizatorDimension) {
		super();
		this.dictionary = dictionary;
		this.quantizatorDimension = quantizatorDimension;
	}

	public Map<Integer, List<Double>> getDictionary() {
		return dictionary;
	}

	public void setDictionary(Map<Integer, List<Double>> dictionary) {
		this.dictionary = dictionary;
	}

	public int getQuantizatorDimension() {
		return quantizatorDimension;
	}

	public void setQuantizatorDimension(int quantizatorDimension) {
		this.quantizatorDimension = quantizatorDimension;
	}
	
	public void addVector(List<Double> vector) {
		this.dictionary.put(nextKey(), vector);
	}
	
	private int nextKey() {
		int toReturn;
		
		if (this.dictionary.keySet().size() == 0) {
			toReturn =  0;
		} else {
			toReturn = Util.maxKey(this.dictionary) + 1;
		}
		
		return toReturn;
	}
	
}

